*  gather variables for 5 year panel of GDPpc & GDPpw growth

cd "~/Documents/econ/research/current/cognitive/estimation/data"

use gdp, clear
merge 1:1 countrycode year using survive, nogen
merge 1:1 countrycode year using BarroLee15, keep(match master) nogen
merge 1:1 countrycode year using ICRG_panel, keep(match master) nogen
merge 1:1 countrycode year using WDI, keep(match) nogen
merge m:1 countrycode using iq, keepusing(iq*) nogen // drop Marshall Islands
encode countrycode, generate(isonum)

order country countrycode isonum year region wb_cat gPWT5 lgdppw lgdppwL25
compress
xtset isonum year, delta(5)
sort countrycode year
saveold growth_panel, replace version(11)

egen samp0 = rowmiss(gPWT5 lgdppw trade_open PRI yr_sch csr_20)
egen samp1 = rowmiss(gPWT5 lgdppw trade_open PRI yr_sch lgdppwL25)

tab year if samp0==0
tab year if samp1==0 & year>=1985
